package com.itheima.a_cookie;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/AgeServlet")
public class AgeServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //默认会话级别
        Cookie ck1 = new Cookie("akey","av");

        Cookie ck2 = new Cookie("autoLogin","jack&1234");
        //持久化保存3天
        ck2.setMaxAge(3*24*60*60);

        response.addCookie(ck1);
        response.addCookie(ck2);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
